package com.funtl.apache.dubbo.log.mq.producer;

import com.funtl.apache.dubbo.log.dto.OrderLogDto;
import com.funtl.apache.dubbo.log.mq.message.OrderMessage;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class OrderProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void product(OrderLogDto orderLogDto) {
        OrderMessage message = new OrderMessage();
        message.setMsgId(UUID.randomUUID().toString());
        message.setOrderId(orderLogDto.getOrderId());
        message.setOrderItemId(orderLogDto.getOrderItemId());

        rocketMQTemplate.convertAndSend("add-order", message);
    }
}
